package urnoted;



import java.util.*;
public class Controller {
    private Staff mStaff;
    private Note mCurrentNote;
    Random ran = new Random();
    private GUI mGui;
    
    public boolean mMostRecentIsCorrect;
    public Note mMostRecentNote;
    
    public Controller(){
        generateNewNote();
    }

    public void setGui(GUI gui)
    {
        mGui = gui;
    }

    public void generateNewNote(){
        mCurrentNote = Note.values()[ran.nextInt(8)];
    }

    public void keyPressed(Note note){
    	mMostRecentNote = note;
        //mStaff.keyPressed(note);
        if (isCurrentNote(note)){
        	mMostRecentIsCorrect = true;
            mGui.getStaffPanel().repaint();
            System.out.println("correct");
            generateNewNote();
        }
        else
        {
        	mMostRecentIsCorrect = false;
        	mGui.getStaffPanel().repaint();
            //paint for couple seconds for red.
        }
    }
    
    public boolean isCurrentNote(Note note){
        if(note!=null && mCurrentNote.equals(note)){
            return true;
        }
        return false;
    }
    
    public Note getCurrentNote(){
        return mCurrentNote;
    }
}
